package izzat.fit.dbservice.service;

import izzat.fit.dbservice.base.service.BaseService;
import izzat.fit.dbservice.entity.action.Action;
import izzat.fit.dbservice.mapper.ActionMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

/**
 * @ClassName: ActionService
 * @Description:
 * @Author: Izzat
 * @Date: 2019-12-29 18:24
 * @Version: v1.0
 */
@Service
public class ActionService implements BaseService {
    @Autowired
    private ActionMapper actionMapper;

    public List<Action> getAllAction(){
        return Optional.ofNullable(actionMapper.getAllAction()).orElse(new ArrayList<>());
    }

    @Override
    public Action findById(Integer integer) {
        return Optional.ofNullable(actionMapper.findById(integer)).orElse(new Action());
    }

    public List<Action> findByPart(String part) {
        return Optional.ofNullable(actionMapper.findByPart(part)).orElse(new ArrayList<>());
    }
}
